# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Dan McGee <dan@archlinux.org>

pkgname=pgbouncer
pkgver=1.18.0
pkgrel=1
pkgdesc='Lightweight connection pooler for PostgreSQL'
url='https://pgbouncer.github.io/'
arch=('x86_64')
license=('BSD')
depends=('glibc' 'libevent' 'c-ares' 'libcares.so' 'systemd' 'pam' 'libpam.so' 'openssl')
makedepends=('asciidoc' 'xmlto')
checkdepends=('postgresql-libs' 'postgresql')
backup=('etc/pgbouncer/pgbouncer.ini'
        'etc/logrotate.d/pgbouncer')
source=(https://pgbouncer.github.io/downloads/files/${pkgver}/pgbouncer-${pkgver}.tar.gz
        pgbouncer.ini
        pgbouncer.logrotate
        pgbouncer.service
        pgbouncer.tmpfiles.conf
        pgbouncer.sysusers)
sha512sums=('1c2bd55c6909a012917fcf1b139ab4bac89de1d02b346b8ade2205c15105a0c6f4f6632bf5844f654cb19e3312b8ed22bf2d14094a17f5515325c826662d5935'
            '39abc7b11c9d7a2593941b4d2a82db998ac1b1e3da131ae276da73c7afc4eda7b69bbfd0acd39f7bce20ecb911baf0adba341ff58dcab1a57e419708e7c8d26f'
            '1dc86704fce211b23afe7962c947c7de80a15bef219928acbf486b915d80d44a6590fbc509fe650c97b694a508bcf95d2152663863f0c372323286e644c6d60a'
            '2b4baaaa7129eda54b34405aa4e15a4d37b2173b529ecae070e766f1dcebd0af8f6898ee1b665a60d5f633036a52662e89967f33caacf2841dad441960230ef7'
            '0757205e5cb5f679bab00bdbed2c828a536239f380d537498bc893c77162e0978308a5f38fae4cb6470f18d6ed0fe4a3ce8f00e85aef89b14bcf6e2eab05a696'
            '05551189022bd160ca0d64831d2559480ae2dcfe8a489aa4c22cc375c3def31d1169e48e17e6502ccd18237d79afef5bc4587f3cf14274c125eb71311d00503b')

build() {
  cd ${pkgname}-${pkgver}
  ./configure \
    --prefix=/usr \
    --disable-debug \
    --with-pam
  make
}

check() {
  cd ${pkgname}-${pkgver}
  make -C test check
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -Dm 644 NEWS.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 COPYRIGHT -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 ../pgbouncer.ini "${pkgdir}/etc/pgbouncer/pgbouncer.ini"
  install -Dm 644 ../pgbouncer.logrotate "${pkgdir}/etc/logrotate.d/pgbouncer"
  install -Dm 644 ../pgbouncer.service "${pkgdir}/usr/lib/systemd/system/pgbouncer.service"
  install -Dm 644 ../pgbouncer.tmpfiles.conf "${pkgdir}/usr/lib/tmpfiles.d/pgbouncer.conf"
  install -Dm 644 ../pgbouncer.sysusers "${pkgdir}/usr/lib/sysusers.d/pgbouncer.conf"
}

# vim: ts=2 sw=2 et:
